<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- designer-manual.qdoc -->
  <title>编辑资源 | Qt Designer 手册</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtdesigner-manual.html">Qt Designer 手册</a></td><td >编辑资源</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtdesigner-manual.html">Qt 5.14.2 参考文档</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
  <link rel="prev" href="designer-creating-mainwindows.html" />
  <link rel="next" href="designer-stylesheet.html" />
<p class="naviNextPrevious headerNavi">
<a class="prevPage" href="designer-creating-mainwindows.html">创建主窗体</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="designer-stylesheet.html">使用样式表</a>
</p><p/>
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#defining-a-resource-file">定义资源文件</a></li>
<li class="level1"><a href="#using-the-resources">使用资源</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">编辑资源</h1>
<span class="subtitle"></span>
<!-- $$$designer-resources.html-description -->
<div class="descr"> <a name="details"></a>
<p class="centerAlign"><img src="images/designer-resources-editing.png" alt="" /></p><p><i>Qt Designer</i> 完全支持 <a href="../qtcore/resources.html">Qt 资源系统</a>, 允许在设计时将资源与窗体一起指定。为了帮助设计人员和开发人员管理他们的应用程序的资源， <i>Qt Designer</i> 的资源编辑器允许在每个窗体的基础上定义资源。换句话说，每个窗体可以有一个单独的资源文件。</p>
<a name="defining-a-resource-file"></a>
<h2 id="defining-a-resource-file">定义资源文件</h2>
<p>要指定资源文件，您必须通过打开 <b>视图(V)</b> 菜单并打开 <b>资源浏览器</b> 选项来启用资源编辑器。</p>
<a name="resourcefiles"></a><div class="table"><table class="generic">
 <tr valign="top" class="odd"><td ><img src="images/designer-resource-browser.png" alt="" /></td><td ><b>资源文件</b><p>在资源浏览器中，您可以打开现有的资源文件或创建新的资源文件。单击 <b>编辑资源（Edit Resources）</b> 按钮<img src="images/designer-edit-resources-button.png" alt="" />编辑您的资源 。要重新加载资源，单击 <b>重新加载（Reload）</b>按钮 <img src="images/designer-reload-resources-button.png" alt="" /> 。</p>
</td></tr>
</table></div>
<p>一旦资源文件被加载，您可以使用给定的 <b>添加文件</b><img src="images/designer-add-resource-entry-button.png" alt="" />和 <b>删除文件</b><img src="images/designer-remove-resource-entry-button.png" alt="" />按钮来创建或删除其中的条目，并使用 <b>添加文件</b>按钮<img src="images/designer-add-files-button.png" alt="" />来指定资源(例如，图像)。请注意，这些资源必须驻留在当前资源文件的目录或其子目录中。</p>
<a name="editresource"></a><div class="table"><table class="generic">
 <tr valign="top" class="odd"><td ><img src="images/designer-edit-resource.png" alt="" /></td><td ><b>编辑资源文件</b><p>按下 <img src="images/designer-add-resource-entry-button.png" alt="" />按钮将新的资源项添加到文件中。然后使用 <b>添加文件</b> 按钮 <img src="images/designer-add-files-button.png" alt="" /> 指定资源。</p>
<p>您可以通过在资源编辑器中选择相应的条目并按下 <img src="images/designer-remove-resource-entry-button.png" alt="" /> 按钮来删除资源。</p>
</td></tr>
</table></div>
<a name="using-the-resources"></a>
<h2 id="using-the-resources">使用资源</h2>
<p>一旦定义了资源，您就可以在编写窗体时积极地使用它们。例如，您可能希望使用资源文件中指定的图标创建工具按钮。</p>
<a name="usingresources"></a><div class="table"><table class="generic">
 <tr valign="top" class="odd"><td ><img src="images/designer-resources-using.png" alt="" /></td><td ><b>使用资源</b><p>当使用可能在资源文件中定义的值更改属性时，<i>Qt Designer</i> 的属性编辑器允许您除了以普通方式选择源文件之外还指定资源。</p>
</td></tr>
<tr valign="top" class="even"><td ><img src="images/designer-resource-selector.png" alt="" /></td><td ><b>选择资源</b><p>您可以通过单击 <b>选择资源…</b> 打开资源选择器。在设计过程中随时添加资源。</p>
</td></tr>
</table></div>
</div>
<!-- @@@designer-resources.html -->
<p class="naviNextPrevious footerNavi">
<a class="prevPage" href="designer-creating-mainwindows.html">创建主窗体</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="designer-stylesheet.html">使用样式表</a>
</p>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
